/*
 * @FilePath: /app/app.cpp
 * @Author: Wilson
 * @Descripttion: 
 * @Date: 2021-08-19 22:26:28
 * @LastEditors: Wilson
 * @LastEditTime: 2021-08-19 23:32:20
 */

#include "app.h"
#include <glog/logging.h>

namespace app
{
    App &App::Instance()
    {
        static App theCT;
        return theCT;
    }

    bool App::Release()
    {
        LOG(INFO) << "App Release";

        if (_plcClient)
        {
            _plcClient->Release();
        }

        return true;
    }

    bool App::Init(Parameters parameters)
    {
        _plcClient = std::make_shared<plc::PLCClient>();
        if (!_plcClient->Init(parameters.plcIPAddress, parameters.readDBList))
        {
            return false;
        }

        _plcClient->WriteDB(1,0,16);
        
        return true;
    }
}